import request from './requst'
import { BannerType, likeCommentType } from '../types'
import { PersonalizedType, songListCommentType } from '../store/modules/songList/type'
import { emailInfoType } from '@renderer/store/modules/userInfo/type'
import loginApi from './module/login'
import userProfileApi from './module/userProfile'
import likeApi from './module/like'
import musicHallApi from './module/musicHall'
// 邮箱登录
export const getEmailLoginApi = (emailInfo: emailInfoType) =>
  request.get<any, any>(`/login?email=${emailInfo.email}&password=${emailInfo.password}`)
// 获取手机验证码
export const getPhoneCodeApi = (phone: string) =>
  request.get<any, any>(`/captcha/sent?phone=${phone}`)
// 手机号验证码登录
export const getPhoneCodeLoginApi = (phoneCodeInfo: any) =>
  request.get<any, any>(
    `/login/cellphone?phone=${phoneCodeInfo.phone}&captcha=${phoneCodeInfo.captcha}`
  )
//获取首页轮播图
export const getBannerApi = () => request.get<any, BannerType>('/banner')
// 获取推荐歌单
export const getPersonalizedApi = (limit = 10) =>
  request.get<any, PersonalizedType>(`/personalized?limit=${limit}`)
// 获取歌单详情
export const getPlayListDetailApi = (id: number) =>
  request.get<any, any>(`/playlist/detail?id=${id}`)
//获取每日推荐歌单
export const getNewSongApi = (limit = 10) =>
  request.get<any, any>(`/personalized/newsong?limit=${limit}`)
// 获取最新专辑
export const getNewAlbumApi = () => request.get<any, any>('/album/newest')
// 获取相似歌曲
export const getSimiSongApi = (id: number) => request.get<any, any>(`/simi/song?id=${id}`)
// 获取音乐url
export const getSongUrlApi = (id: number) =>
  request.get<any, any>(`/song/url?id=${id}&level=exhigh`)
//获取歌曲详情
export const getSongDetailApi = (ids: number) => request.get<any, any>(`/song/detail?ids=${ids}`)
// 搜索type: 搜索类型；默认为 1 即单曲 , 取值意义 : 1: 单曲, 10: 专辑, 100: 歌手, 1000: 歌单, 1002: 用户, 1004: MV, 1006: 歌词, 1009: 电台, 1014: 视频, 1018:综合, 2000:声音(搜索声音返回字段格式会不一样)
export const getSearchByTypeApi = (params: { keywords: string, type: number }) =>
  request.get<any, any>(`/cloudsearch?keywords=${params.keywords}&type=${params.type}`)
// 搜索歌手
export const getSearchSingerApi = (keywords: string) =>
  request.get<any, any>(`/ugc/artist/search?keyword=${keywords}`)

//歌手热门歌曲
export const getSingerHotSongApi = (id: number) =>
  request.get<any, any>(`/artist/top/song?id=${id}`)
// 搜索建议
export const getSearchSuggestApi = (keywords: string) =>
  request.get<any, any>(`/search/suggest?keywords=${keywords}`)
// 获取歌词
export const getLyricApi = (id: number) => request.get<any, any>(`/lyric?id=${id}`)
// 获取热门歌单
export const getHotPlaylistApi = () => request.get<any, any>('/playlist/hot')
// 获取歌单评论
export const getSongListCommentApi = (id: number) =>
  request.get<any, songListCommentType>(`/comment/playlist?id=${id}`)
// 给评论点赞
export const likeCommentApi = (likeComment: likeCommentType) =>
  request.get<any, any>(
    `/comment/like?id=${likeComment.id}&cid=${likeComment.cid}&t=${likeComment.t}&type=${likeComment.type}`
  )
// 获取推荐视频列表
export const getVideoListApi = () => request.get<any, any>('/personalized/mv')
// 获取最新mv
export const getNewMvApi = (limit: number) => request.get<any, any>('/mv/first?limit=' + limit)
export const getWyMvApi = (limit: number) => request.get<any, any>('/mv/exclusive/rcmd?limit=' + limit)
// 获取mv信息
export const getMvUrlApi = (id: number) => request.get<any, any>('/mv/url?id=' + id)
export const getTopMvListApi = (params: { limit: number, area: string }) => request.get<any, any>(`/top/mv?limit=${params.limit}&area=${params.area}`)
export const getAllMvApi = (params: { order: string, limit: number, area: string, type: string }) => request<any, any>({
  method: 'GET',
  url: '/mv/all',
  params
})
// 获取精品歌单
export const getHighQualityListApi = () => request.get<any, any>('/top/playlist/highquality?limit=3')
// 获取全部歌单
export const getAllSongListCatApi = () => request.get<any, any>(`/playlist/catlist`)
// 获取分类歌单id
export const getSongListIdBycatApi = (cat: string) => request.get<any, any>(`/top/playlist?cat=${cat}&order=hot&limit=1`)
// 获取歌曲评论
export const getSongCommentApi = (id: number) => request.get<any, any>(`/comment/music?id=${id}&limit=50`)
//
export const getAblumDetailApi = (id: number) => request.get<any, any>(`/album?id=${id}`)

export default {
  loginApi,
  userProfileApi,
  likeApi,
  musicHallApi,
}